import { defineComponent, DefineComponent } from 'vue'
/**
 * @description 此子组件曝光混入不适合layout 组件的子组件在mounted 执行，如有需求，请延迟时间执行
 */
export default defineComponent({
  methods: {
    pageComponent () {
      if (this.$root && this.$root.$refs.pageComponent) {
        return this.$root.$refs.pageComponent
      }
    },
    appendShowTrackData (showName:string) {
      const pageComponent = this.pageComponent()
      if ((pageComponent as DefineComponent).appendShowTrackData) {
        (pageComponent as DefineComponent).appendShowTrackData(showName)
      }
    },
    appendClickTrackData (clickName:string) {
      const pageComponent = this.pageComponent()
      if ((pageComponent as DefineComponent).appendClickTrackData) {
        (pageComponent as DefineComponent).appendClickTrackData(clickName)
      }
    },
    postTrackData () {
      const pageComponent = this.pageComponent()
      if ((pageComponent as DefineComponent).postTrackData) {
        (pageComponent as DefineComponent).postTrackData()
      }
    }
  }
})
